<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <script type="text/javascript" src="../js/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/jquery.bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.form.js"></script>
    <script type="text/javascript" src="../js/plugins/jquery.twbsPagination.min.js"></script>
    <script type="text/javascript">
        function toPage(page) {
            $("#myfrom").attr("action", "realAuthselect?currPage=" + page);
            $("#myfrom").submit();
        }


        $(function () {
            var state = '${realauth.state}';
            //alert(grade);
            if (state == '') {
                state = -2;
            }
            $("[name='state']").val(state);//获得状态下拉框默认的值

            //拿到当前页
            var currPage = ${pager.currPage};
            //拿到最后一页
            var totalPages = ${pager.totalPages};

            if (currPage <= 1) {
                $("#prev").removeAttr("href");
            }

            if (currPage >= totalPages) {
                $("#next").removeAttr("href");
            }

            $(".btn_audit").click(function(){
                var form=$("#editform");
                form.find("[name=state]").val($(this).val());
                $("#myModal").modal("hide");

                form.ajaxSubmit(function(data){

                    if(data.success){
                        $.messager.confirm("提示",data.msg,function(){
                            window.location.reload(true);
                        });
                    }else{
                        $.messager.confirm("提示","系统故障，操作失败");
                    }
                });
                return false;
            });

            $(".auditClass").click(function () {
                var json = $(this).data('json');
                $("#realauthId").val(json.realauthId);
                $("#applierName").html(json.applier);
                $("#realName").html(json.realName);
                $("#sex").html(json.sex);
                $("#idNumber").html(json.idNumber);
                $("#address").html(json.address);
                $("#bornDate").html(json.bornDate);
                $("#image1").attr("src", json.image1);
                $("#image2").attr("src", json.image2);
                $('#myModal').modal("show");
            })

        });

        function aa() {
            $("[name='state']").val("-2");
            $("[name='time1']").val("");
            $("[name='time2']").val("");
        }


    </script>

</head>

<body>

<c:if test="${param.op == 'delYes' }">
    <script>
        alert("删除成功");
    </script>
</c:if>
<c:if test="${param.op == 'delNo' }">
    <script>
        alert("删除失败");
    </script>
</c:if>
<c:if test="${param.op == 'insertYes' }">
    <script>
        alert("新增成功");
    </script>
</c:if>
<c:if test="${param.op == 'insertNo' }">
    <script>
        alert("新增失败");
    </script>
</c:if>
<div style="width: 200px; float: left;margin-left: 150px;margin-top: 100px"    >
    <li class="list-group-item" >
        <a href="#" data-toggle="collapse" data-target="#auditmanage_detail">
            <span>审核项目</span>
        </a>
        <ul class="in" id="auditmanage_detail">
            <li class="realAuth">
                <a href="./realAuthselect">实名认证审核</a>
            </li>
            <li class="vedioAuth">
                <a href="./vedioAuthselect">视频认证审核</a>
            </li>
            <li class="userFileAuth">
                <a href="./userFileselect">认证材料审核</a>
            </li>
            <li class="bidrequest_publishaudit_list">
                <a href="./bidRequestSelect">发标前审核</a>
            </li>
            <li class="bidrequest_audit1_list">
                <a href="./bidRequestSelect1">满标一审</a>
            </li>
            <li class="bidrequest_audit2_list">
                <a href="./bidRequestSelect2">满标二审</a>
            </li>
        </ul>
    </li>
</div>
<div style="width: 1000px; float: left;margin-top: 50px;margin-left: 50px">
<center>
    <h1>实名审核管理</h1>
</center>
<form id="myfrom" action="./realAuthselect" method="post">

    <center>
        状态
        <select name="state">
            <option value="-2">全部</option>
            <option value="0">申请状态</option>
            <option value="1">审核成功</option>
            <option value="-1">审核拒绝</option>
        </select>

        申请时间<input type="text" name="time1" value="${time1}"/>
        到&nbsp;<input type="text" name="time2" value="${time2}"/>
        <input type="submit" value="查询"/>

        <input type="button" onclick="aa()" value="重置"/>
        <Br/>
    </center>
    <table align="center" width="70%" border="1px" class="table">
        <tr align="center">
            <td>用户名</td>
            <td>真实姓名</td>
            <td>性别</td>
            <td>身份证号</td>
            <td>身份证地址</td>
            <td>状态</td>
            <td>审核人</td>
        </tr>
        <c:forEach items="${list}" var="user" varStatus="st">
            <tr align="center"
                    <c:if test="${st.index %2 ==0 }">
                        style="background-color:gray"
                    </c:if>
            >
                <input type="hidden" name="realauthId" value="${user.realauthId}">
                <td>${user.applier.userName }</td>
                <td>${user.realName }</td>
                <td>
                    <c:if test="${user.sex== 0 }">男</c:if>
                    <c:if test="${user.sex== 1 }">女</c:if>

                </td>
                <td>${user.idNumber }</td>
                <td>${user.address }</td>
                <td>
                    <c:if test="${user.state== 0 }">申请状态</c:if>
                    <c:if test="${user.state== 1 }">审核通过</c:if>
                    <c:if test="${user.state==-1 }">审核拒绝</c:if>
                </td>
                <td>${user.auditor.userName }</td>
                <td>
                    <c:if test="${ empty user.auditor.userName}">
                        <a class="auditClass"
                           data-json='{"realName":"${user.realName}","applier":"${user.applier.userName}"
                                ,"sex":"${user.getSexDisplay()}"
                                ,"idNumber":"${user.idNumber}","bornDate":"${user.bornDate}","realauthId":"${user.realauthId}"
                                ,"address":"${user.address}","image1":"${user.image1}","image2":"${user.image2}" }'>
                            <button id="btn_add" type="button" class="btn btn-primary">审核</button>
                        </a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
    </table>

    <center>
        <a href="javaScript:toPage(1)">首页</a>&nbsp;&nbsp;
        <a id="prev" href="javaScript:toPage(${pager.currPage-1 })">上一页</a>&nbsp;&nbsp;
        <a id="next" href="javaScript:toPage(${pager.currPage+1 })">下一页</a>&nbsp;&nbsp;
        <a href="javaScript:toPage(${pager.totalPages})">尾页</a>&nbsp;&nbsp;
        <span>第${pager.currPage }页/共${pager.totalPages }页</span>
    </center>
</form>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <form class="form-horizontal" id="editform" method="post" action="./realAuthUpdate">
                        <fieldset>
                            <div id="legend" class="">
                                <legend>实名认证审核</legend>
                            </div>
                            <input type="hidden" name="realauthId" id="realauthId" value="">
                            <input type="hidden" name="state" id="state" value="">
                            <div class="row">
                                <label class="col-sm-2 control-label" >用户名</label>
                                <div class="col-sm-4">
                                    <label class="form-control" name="applierName" id="applierName"></label>
                                </div>
                                <label class="col-sm-2 control-label" >真实姓名</label>
                                <div class="col-sm-4">
                                    <label class="form-control" name="realName" id="realName"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-2 control-label" >身份证号</label>
                                <div class="col-sm-4">
                                    <label class="form-control" name="idNumber" id="idNumber"></label>
                                </div>
                                <label class="col-sm-2 control-label" >性别</label>
                                <div class="col-sm-4">
                                    <label class="form-control" id="sex"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-2 control-label" >生日</label>
                                <div class="col-sm-4">
                                    <label class="form-control" id="bornDate"></label>
                                </div>
                                <label class="col-sm-2 control-label" >身份证地址</label>
                                <div class="col-sm-4">
                                    <label class="form-control" id="address"></label>
                                </div>
                            </div>
                            <div class="row">
                                <label class="col-sm-2 control-label" >身份证正面</label>
                                <div class="col-sm-4">
                                    <img src="" id="image1" style="width: 100px;">
                                </div>
                                <label class="col-sm-2 control-label" >身份证背面</label>
                                <div class="col-sm-4">
                                    <img src="" id="image2" style="width: 100px;">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" >审核备注</label>
                                <div class="col-sm-6">
                                    <textarea name="remark" rows="7" cols="60"></textarea>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-success btn_audit" value="1">审核通过</button>
                    <button type="button" class="btn btn-warning btn_audit" value="-1">审核拒绝</button>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
</html>
